home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 026-050 / scopedisk46 / mj-pgs / j-size.asc < prev    next >
Text File  |  1995-03-18  |  4KB  |  86 lines

  1.           push      a7                  save all registers
  2.           lea       -106(pc),a5         pointer to variables
  3.           move.l    396(a5),d0          holds re
  4.           move.l    400(a5),d4          holds im
  5.           movea.l   #0,a0               initialize counter
  6.           movea.l   4(a5),a1            holds cr
  7.           movea.l   8(a5),a2            holds ci
  8.           bra       Start
  9. L180      addq.w    #1,a0               increment counter
  10.           sub.l     a6,d7               re2-im2
  11.           add.l     a1,d7               re2-im2+cr
  12.           moveq     #0,d3               initialize flag
  13.           move.l    d0,16(a5)           tempstow re
  14.           bpl       Plus1
  15.           moveq     #1,d3               found one negative number
  16.           neg.l     16(a5)
  17. Plus1     move.l    d4,20(a5)           tempstow im
  18.           bpl       Plus2
  19.           addq.l    #1,d3               found another negative number
  20.           neg.l     20(a5)
  21. Plus2     move.w    16(a5),d1           multiply 2*re*im routine
  22.           mulu      22(a5),d1           including dividing by 2^28
  23.           move.w    18(a5),d2           and left shift for 2*
  24.           mulu      20(a5),d2
  25.           add.l     d2,d1
  26.           moveq     #11,d6
  27.           lsr.l     d6,d1
  28.           move.w    18(a5),d2
  29.           mulu      22(a5),d2
  30.           moveq     #27,d6
  31.           lsr.l     d6,d2
  32.           add.l     d2,d1
  33.           move.w    16(a5),d2
  34.           mulu      20(a5),d2
  35.           lsl.l     #5,d2
  36.           add.l     d2,d1
  37.           cmpi.b    #1,d3               if exactly one negative number
  38.           bne       Plus3               then answer is negative
  39.           neg.l     d1
  40. Plus3     add.l     a2,d1
  41.           move.l    d1,d4               im=2*re*im+ci
  42.           move.l    d7,d0               re=tempstow
  43. Start     moveq     #0,d3               flag for re2 or im2 too big
  44.           move.l    d0,16(a5)           set up square routine
  45.           bsr       Square
  46.           tst.b     d3
  47.           bne       Out                 re2 exceeds limit
  48.           move.l    d1,d7               tempstow re2
  49.           move.l    d4,16(a5)           set up square routine
  50.           bsr       Square
  51.           tst.b     d3
  52.           bne       Out                 im2 exceeds limits
  53.           move.l    d1,a6               store im2
  54.           add.l     d7,d1               re2+im2
  55.           cmpa.l    (a5),a0
  56.           beq       Out1                equals max iterations
  57.           cmp.l     #1073741824,d1
  58.           bmi.w     L180                distance still less than 2
  59. Out       move.l    a0,12(a5)           move count to variable para(3)
  60.           pop       a7                  unsave registers
  61.           rts                           return to BASIC
  62. Square    bpl       Plus4
  63.           neg.l     16(a5)
  64. Plus4     move.w    18(a5),d1           square routine using formula
  65.           mulu      18(a5),d1           (a+b)^2=a^2+2ab+b^2
  66.           moveq     #28,d6
  67.           lsr.l     d6,d1
  68.           move.w    16(a5),d2
  69.           mulu      18(a5),d2
  70.           moveq     #11,d6
  71.           lsr.l     d6,d2
  72.           add.l     d2,d1
  73.           move.w    16(a5),d2
  74.           mulu      16(a5),d2
  75.           cmp.l     #67108864,d2
  76.           spl       d3                  set flag if square exceeds limit
  77.           lsl.l     #4,d2
  78.           add.l     d2,d1
  79.           rts
  80. Out1      cmp.l     #1073741824,d1
  81.           bge       Out
  82.           move.l    392(a5),d3
  83.           lsr.l     d3,d1               divide re^2+im^2 by 2^para(98)
  84.           adda.l    d1,a0               add count and scaled size
  85.           bra       Out
  86.